package com.ljw.my.session;
import com.ljw.my.executor.Executor;
import com.ljw.my.proxy.MapperProxy;
import com.ljw.my.executor.SimpleExecutor;

import java.lang.reflect.Proxy;

public class MySqlSession {
    private Executor executor = new SimpleExecutor();

    public <T> T selectOne(String statement, Object parameter) {
        System.out.println("--statement--"+statement+"---parameter--"+ parameter);
        executor.query(statement, parameter);
        return executor.query(statement,parameter);
    }

    public <T> T getMapper(Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new MapperProxy<T>(this, clazz));
    }
}
